package com.model.pool;

import com.face.ConstantDecorate;
import com.model.ClassInfo;
import com.model.structure.ConstantPool;
import com.util.Analysis;
import com.util.SystemNumber;
import lombok.Data;

/**
 * @author seven
 */
@Data
public class ConstantFieldInfo extends BaseConstantDecorate implements ConstantDecorate {
    private Integer classIndex;
    private Integer classIndexLen=2;
    private Integer typeIndex;
    private Integer typeIndexLen=2;



    /**
     * 解析field常量
     * @param info
     */
    @Override public void invoke(ClassInfo info, Analysis analysis,int tag) {
        if(tag == SystemNumber.NINE){
            this.setClassIndex(analysis.util.sixteenToTenInt(analysis.readValue(this.getClassIndexLen())));
            this.setTypeIndex(analysis.util.sixteenToTenInt(analysis.readValue(this.getTypeIndexLen())));
            this.setConstantPoolInfoType("CONSTANT_Fieldref_info");
            this.setTag(tag);
            info.getPoolList().add(this);
        }else{
            new ConstantFloatInfo().invoke(info,analysis,tag);
        }
    }
}
